<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="/js/jquery-3.5.1.min.js"></script>
</head>
<body>
<form action="/demo02/demo05" method="post">

    <input type="text" name="id">
    <input type="text" name="name">

    <input type="submit">
</form>

<button id="btn">sendRequest</button>

<script>

    $(function () {
        $("#btn").click(function () {
            var province = {id: 1, name: "LiaoNing"}
            $.post({
                url: "/demo02/demo05",

                // 使用表单的请求方式(这也是默认的请求类型)
                contentType: "application/json",
                data: JSON.stringify(province),				// 直接提交JSON对象
                success: function (res) {

                    console.log(res);
                }
            })
        })
    })
</script>
</body>
</html>
